/**
 *  Copyright 2011 Pavlov Dm.
 *  Licensed under the MIT License
 */

package org.motiv.policy;

import org.motiv.core.Element;
/**
 * An eviction policy.
 * @author Pavlov Dm
 */
public interface Policy {
    /**
     * @return the name of the Policy. Inbuilt examples are LRU, LFU and FIFO.
     */
    String getName();
    /**
     * Finds the best eviction candidate based on the sampled elements. 
     * @param sampledElements this should be a random subset of the population
     * @param justAdded       we probably never want to select the element just added.
     * It is provided so that it can be ignored if selected. May be null.
     * @return the selected Element
     */
    Element selectedBasedOnPolicy(Element[] sampledElements, Element justAdded);
    /**
     * Compares the desirableness for eviction of two elements
     * @param element1 the element to compare against
     * @param element2 the element to compare
     * @return true if the second element is preferable for eviction to the first element
     * under ths policy
     */
    boolean compare(Element element1, Element element2);
}
